//
//  CAGradientLayerExtension.swift
//  BadAir
//
//  Created by D on 2018/3/10.
//  Copyright © 2018年 D. All rights reserved.
//

import UIKit

extension CAGradientLayer{
    
    func rainbowLayer(color: [CGColor]) -> CAGradientLayer {
        let gradientColors = color
        
        //定义每种颜色所在的位置
        let gradientLocations:[NSNumber] = [0.0 , 1.0]
        
        //创建CAGradientLayer对象并设置参数
        colors = gradientColors
        locations = gradientLocations
        
        //设置渲染的起始结束位置（横向渐变）
        startPoint = CGPoint(x: 0, y: 0)
        self.endPoint = CGPoint(x: 1, y: 0)
        
        return self
    }
}
